package com.ruoyi.web.controller.gym;

import com.ny.domain.GroupCourseInfoDO;
import com.ny.domain.PersonalTrainerCourseDO;
import com.ny.dto.CourseReservationDTO;
import com.ny.dto.CreateGroup;
import com.ny.dto.DeleteGroup;
import com.ny.dto.GroupCourseInfoDTO;
import com.ny.dto.PersonalTrainerCourseDTO;
import com.ny.dto.RestResult;
import com.ny.query.GroupCourseInfoQuery;
import com.ny.query.PersonalTrainerCourseQuery;
import com.ny.query.QueryGroup;
import com.ny.service.CourseService;
import com.ny.vo.PrivateCourseVO;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.lang.Boolean;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 课程管理模块
 *
 * @author MSI-NB
 * @date 2025-03-08 13:14:38
 */
@Api("课程管理模块")
@RequestMapping("course")
@RestController
public class CourseController extends BaseController {

    @Autowired
    private CourseService courseService;

    /**
     * 发布私教课程
     *
     * @param personalTrainerCourseDTO 发布私教课程入参
     * @return
     */
    @RequestMapping(value = "/personal/add", method = RequestMethod.POST)
    @ApiOperation("发布私教课程")
    @ResponseBody
    public RestResult<Boolean> addPersonalTrainerCourse(@RequestBody @Validated(CreateGroup.class) PersonalTrainerCourseDTO personalTrainerCourseDTO) {
        Boolean result = courseService.addPersonalTrainerCourse(personalTrainerCourseDTO);
        return RestResult.success(result);
    }

    /**
     * 发布团队课程
     *
     * @param groupCourseInfoDTO 发布团队课程入参
     * @return
     */
    @RequestMapping(value = "/group/add", method = RequestMethod.POST)
    @ApiOperation("发布团队课程")
    @ResponseBody
    public RestResult<Boolean> addGroupCourseInfo(@RequestBody @Validated(CreateGroup.class) GroupCourseInfoDTO groupCourseInfoDTO) {
        Boolean result = courseService.addGroupCourseInfo(groupCourseInfoDTO);
        return RestResult.success(result);
    }

    /**
     * 查询私教课程
     *
     * @param personalTrainerCourseQuery 查询私教课程入参
     * @return
     */
    @RequestMapping(value = "/personal/list", method = RequestMethod.POST)
    @ApiOperation("查询私教课程")
    public TableDataInfo getPersonalTrainerCourseInfo(@RequestBody PersonalTrainerCourseQuery personalTrainerCourseQuery) {
        List<PrivateCourseVO> result = courseService.getPersonalTrainerCourseInfo(personalTrainerCourseQuery);



        return getDataTable(result);
    }

    /**
     * 查询团队课程
     *
     * @param groupCourseInfoQuery 查询团队课程入参
     * @return
     */
    @RequestMapping(value = "/group/list", method = RequestMethod.POST)
    @ApiOperation("查询团队课程")
    public RestResult<List<GroupCourseInfoDO>> getGroupCourseInfo(@RequestBody GroupCourseInfoQuery groupCourseInfoQuery) {
        List<GroupCourseInfoDO> result = courseService.getGroupCourseInfo(groupCourseInfoQuery);
        return RestResult.success(result);
    }

    /**
     * 预约私教课程
     *
     * @param courseReservationDTO 预约课程入参
     * @return
     */
    @RequestMapping(value = "/personal/reserve", method = RequestMethod.POST)
    @ApiOperation("预约私教课程")
    @ResponseBody
    public RestResult<Boolean> reservePersonalTrainerCourse(@RequestBody @Validated(CreateGroup.class) CourseReservationDTO courseReservationDTO) {
        Boolean result = courseService.reservePersonalTrainerCourse(courseReservationDTO);
        return RestResult.success(result);
    }

    /**
     * 预约团队课程
     *
     * @param courseReservationDTO 预约课程入参
     * @return
     */
    @RequestMapping(value = "/group/reserve", method = RequestMethod.POST)
    @ApiOperation("预约团队课程")
    @ResponseBody
    public RestResult<Boolean> reserveGroupCourse(@RequestBody @Validated(CreateGroup.class) CourseReservationDTO courseReservationDTO) {
        Boolean result = courseService.reserveGroupCourse(courseReservationDTO);
        return RestResult.success(result);
    }

    /**
     * 取消私教课程预约
     *
     * @param courseReservationDTO 预约课程入参
     * @return
     */
    @RequestMapping(value = "/personal/reserve", method = RequestMethod.DELETE)
    @ApiOperation("取消私教课程预约")
    @ResponseBody
    public RestResult<Boolean> cancelPersonalTrainerCourseReservation(@RequestBody @Validated(DeleteGroup.class) CourseReservationDTO courseReservationDTO) {
        Boolean result = courseService.cancelPersonalTrainerCourseReservation(courseReservationDTO);
        return RestResult.success(result);
    }

    /**
     * 取消团队课程预约
     *
     * @param courseReservationDTO 预约课程入参
     * @return
     */
    @RequestMapping(value = "/group/reserve", method = RequestMethod.DELETE)
    @ApiOperation("取消团队课程预约")
    @ResponseBody
    public RestResult<Boolean> cancelGroupCourseReservation(@RequestBody @Validated(DeleteGroup.class) CourseReservationDTO courseReservationDTO) {
        Boolean result = courseService.cancelGroupCourseReservation(courseReservationDTO);
        return RestResult.success(result);
    }
}
